package diseaseandcureadministration.cure;

import java.util.ArrayList;

/**
 * CureCreator is a concrete factory defined by
 * ICureCreator.
 * 
 * @author Peter Tolstrup Aagesen, ptaa@itu.dk
 *
 */
public class CureCreator implements ICureCreator{
	
	//Instance variable
	private ArrayList<Cure> knownCures = new ArrayList<Cure>();
	
	public CureCreator() {
		//Define known cures
		knownCures.add(new SprayCure("Asthma Spray", 10));
		knownCures.add(new PillBasedCure("Penicillin", 30));
		knownCures.add(new PillBasedCure("Antibiotics", 30));
		knownCures.add(new SmokeBasedCure("Weed", 5)); 
		knownCures.add(new InjectedCure("Injected Antibiotics", 50));
	}
	
	@Override
	public Cure getCure(String name)
	{
		//Set foundCure to null per default
		Cure foundCure = null;
		
		//Traverse knownCures for a matching cure
		for(Cure cure: knownCures)
		{
			if(cure.getName().equalsIgnoreCase(name))
			{
				foundCure = cure;
			}
		}
		
		//Return result
		return foundCure;
	}

}
